package com.dai.designpattern.singleton.lazy;

/**
 * @author daijiyong
 */
public class LazyStaticInnerClassSingleton {
    private LazyStaticInnerClassSingleton() {
        //防止通过Java反射机制创建实例
        if (LazyHolder.INSTANCE != null) {
            throw new RuntimeException("不允许非法访问");
        }
    }

    private static LazyStaticInnerClassSingleton getInstance() {
        return LazyHolder.INSTANCE;
    }

    private static class LazyHolder {
        private static final LazyStaticInnerClassSingleton INSTANCE = new LazyStaticInnerClassSingleton();
    }
}
